#!/bin/bash

# 定义要检查的目录数组
directories=("test1" "test2" "test3" "test4" "test5" "test6" "test7" "test8" "test9" "test10")

# 遍历目录数组
for dir in "${directories[@]}"; do
    cd "$dir" || {
        echo "无法进入目录 $dir，跳过。"
        continue
    }

    if [ -f "makefile" ]; then
        make
        executable_file="$dir"
        if [ -x "$executable_file" ]; then
            "./$executable_file"
        else
            echo "Make 成功，但未找到可执行文件 $executable_file。"
        fi
    else
        python_file=$(ls -1 *.py 2>/dev/null | head -n 1)
        if [ -n "$python_file" ]; then
            python3 "$python_file"
        else
            echo "目录 $dir 中既没有 Makefile 也没有 Python 文件。"
        fi
    fi

    cd ../
done
